package logic

import (
	"context"
	"shuqi-novel/models"

	"shuqi-novel/novelrpc/internal/svc"
	"shuqi-novel/novelrpc/novelrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type BookListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewBookListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BookListLogic {
	return &BookListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 小说列表
func (l *BookListLogic) BookList(in *novelrpc.BookListRequest) (*novelrpc.BookListResponse, error) {
	// todo: add your logic here and delete this line

	var book models.Book

	var books []*novelrpc.BookList

	list, err := book.BookList(models.DB, books)
	if err != nil {
		return nil, err
	}

	return &novelrpc.BookListResponse{
		List: list,
	}, nil
}
